//
//  XiangQingCell.m
//  MyTest
//
//  Created by zhiyou on 16-4-23.
//  Copyright (c) 2016年 wangyang. All rights reserved.
//

#import "XiangQingCell.h"

@implementation XiangQingCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _imgView = [[UIImageView alloc] init];
        [self.contentView addSubview:_imgView];
        _titleLab = [[UILabel alloc] init];
        _titleLab.numberOfLines = 2;
        _titleLab.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_titleLab];
        _subLab = [[UILabel alloc] init];
        _subLab.font = [UIFont systemFontOfSize:14];
        _subLab.textColor = [UIColor redColor];
        [self.contentView addSubview:_subLab];
        _btn = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn.titleLabel.font = [UIFont systemFontOfSize:14];
        [_btn setTitle:@"收藏" forState:UIControlStateNormal];
        [_btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.contentView addSubview:_btn];
        
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.offset(0);
            make.height.equalTo(_imgView.mas_width);
        }];
        
        [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(10);
            make.top.equalTo(_imgView.mas_bottom).offset(10);
            make.width.equalTo(self.mas_width).multipliedBy(0.8);
        }];
        
        [_subLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(10);
            make.top.equalTo(_titleLab.mas_bottom).offset(10);
        }];
        
        [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_titleLab.mas_right).offset(10);
            make.top.equalTo(_imgView.mas_bottom).offset(10);
            make.right.offset(-10);
            make.height.equalTo(_btn.mas_width);
        }];
        
    }
    return self;
}
- (void)setXiangQing:(XiangQing *)xiangQing
{
    _xiangQing = xiangQing;
    [_imgView sd_setImageWithURL:[NSURL URLWithString:_xiangQing.img]];
    _titleLab.text = _xiangQing.title;
    _subLab.text = _xiangQing.subtitle;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
